using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using Utility;
using DTO;

namespace BUS
{
   public class tbtinhtrangsanphamBUS
    {
        public static tbtinhtrangsanphamcollection Get(string where,
       int pageindex,
       int pagesize,
       string orderby,
       string orderdirection,
       out int total)
        {
            tbtinhtrangsanphamDAL tinhtrangsanphamDAL = new tbtinhtrangsanphamDAL();
            return tinhtrangsanphamDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
       public static tbtinhtrangsanphamcollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbtinhtrangsanphamDAL tinhtrangsanphamDAL = new tbtinhtrangsanphamDAL();
            return tinhtrangsanphamDAL.Get(cri.Criter, 0, 0, tinhtrangsanphamcolumns.matinhtrangsanpham.ToString(), OrderDirection.ASC.ToString(), out total);
        }
       public static tbtinhtrangsanpham GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tinhtrangsanphamcolumns.matinhtrangsanpham.ToString(), Condition.EQUAL, iD);
            tbtinhtrangsanphamDAL tinhtrangsanphamDAL = new tbtinhtrangsanphamDAL();
            tbtinhtrangsanphamcollection tinhtrangsanphamcollection = tinhtrangsanphamDAL.Get(cri.Criter,
                     0, 0, tinhtrangsanphamcolumns.matinhtrangsanpham.ToString(), OrderDirection.ASC.ToString(), out total);
            if (tinhtrangsanphamcollection.Count > 0)
                return tinhtrangsanphamcollection[0];
            return null;
        }
    }
}
